home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Images and Bitmaps / DualWink / DualWink.cs next >
Encoding:
Text File  |  2001-01-15  |  1.4 KB  |  52 lines

  1. //---------------------------------------
  2. // DualWink.cs ⌐ 2001 by Charles Petzold
  3. //---------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class DualWink: Wink
  9. {
  10.      Image[] aimageRev = new Image[4];
  11.  
  12.      public new static void Main()
  13.      {
  14.           Application.Run(new DualWink());
  15.      }
  16.      public DualWink()
  17.      {
  18.           Text = "Dual " + Text;
  19.  
  20.           for(int i = 0; i < 4; i++)
  21.           {
  22.                aimageRev[i] = (Image) aimage[i].Clone();
  23.                aimageRev[i].RotateFlip(RotateFlipType.RotateNoneFlipX);
  24.           }
  25.      }
  26.      protected override void TimerOnTick(object obj, EventArgs ea)
  27.      {
  28.           Graphics grfx = CreateGraphics();
  29.  
  30.           grfx.DrawImage(aimage[iImage], 
  31.                     ClientSize.Width / 2,
  32.                     (ClientSize.Height - aimage[iImage].Height) / 2,
  33.                     aimage[iImage].Width, aimage[iImage].Height);
  34.  
  35.           grfx.DrawImage(aimageRev[3 - iImage],
  36.                     ClientSize.Width / 2 - aimageRev[3 - iImage].Width,
  37.                     (ClientSize.Height - aimageRev[3 - iImage].Height) / 2,
  38.                     aimageRev[3 - iImage].Width,
  39.                     aimageRev[3 - iImage].Height);
  40.  
  41.           grfx.Dispose();
  42.  
  43.           iImage += iIncr;
  44.  
  45.           if (iImage == 3)
  46.                iIncr = -1;
  47.           
  48.           else if (iImage == 0)
  49.                iIncr = 1;
  50.      }
  51. }
  52.